package com.fullhome8.cn.wanghongweb.controller;

import com.fullhome8.cn.wanghongweb.annotation.Authorization;
import com.fullhome8.cn.wanghongweb.model.News;
import com.fullhome8.cn.wanghongweb.service.NewService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class IndexController {

    @Autowired
    private NewService newService;

    @RequestMapping(value = "/index")
    @Authorization
    public String helloWord(HttpServletRequest request, HttpServletResponse response) {
        List<News> news = newService.queryNewsList();
        request.setAttribute("news", news.get(2));
        return "index";
    }

}
